/**
* hash.js
*
* Copyright (C) 2012 Emmanuel Garcia
* MIT Licensed
*
* ****************************************
*
* Hash.pushState(true);
*
* Hash.on('/page/([0-9]+)$',
*	{yep: function(path, parts) { }, nop: function() { }},
*	'Page $1');
*
* Hash.go('/page/1');
**/

(function () {

    'use strict';

    var hashes = {},
	regexp = {},
	history = [],
	freq = 100,
	num = 0,
	pushState = false,
	timer = null,
	currentUrl = null,

	freeze = function (obj) {
	    if (Object.freeze) return Object.freeze(obj);
	    return obj;
	},

	getHashParts = function () {
	    return window.location.href.split('#');
	},

	startTimer = function () {

	    if (!timer)
	        timer = setInterval(function () {
	            if (num > 0 && currentUrl != window.location.href) {
	                currentUrl = window.location.href;
	                window.Hash.check();
	            }
	        }, freq);

	},

	stopTimer = function () {

	    if (timer) {
	        clearInterval(timer);
	        timer = null;
	    }

	};

    window.Hash = freeze({

        pushState: function (yes) {

            if (window.history && window.history.pushState)
                pushState = yes;

            return this;
        },

        fragment: function () {

            var hash = getHashParts();
            return (pushState) ?
				window.location.pathname + ((hash[1]) ? '#' + hash[1] : '')
				: hash[1] || '';

        },

        get: function (path, params) {

            var p, fragment = '', parameters = [];

            for (p in params) {
                if (!Object.prototype.hasOwnProperty(p))
                    continue;
                parameters.push(encodeURIComponent(p) + '=' + encodeURIComponent(params[p]));
            }

            if (parameters.length > 0)
                parameters = '?' + parameters.join('&');

            return (pushState) ? path + parameters :
				getHashParts()[0] + '#' + path + parameters;

        },

        go: function (hash, params) {

            if (this.fragment() != hash) {
                var to = this.get(hash, params);

                if (pushState)
                    window.history.pushState(null, document.title, to);
                else
                    window.location.href = to;
            }

            return this;
        },

        update: function () {

            currentUrl = window.location.href;
            return this;

        },

        on: function (hash, callback, title) {

            if (!hashes[hash])
                hashes[hash] = { title: title, listeners: [] };

            hashes[hash].listeners.push(callback);
            num++;
            startTimer();

            return this;
        },

        check: function () {

            var i,
				hash,
				parts,
				fragment = this.fragment();


            for (hash in hashes) {
                if (!Object.prototype.hasOwnProperty.call(hashes, hash))
                    continue;

                hashes[hash].regexp = hashes[hash].regexp || new RegExp(hash);

                if ((parts = hashes[hash].regexp.exec(fragment))) {
                    if (hashes[hash].title)
                        document.title = hashes[hash].title;

                    for (i = 0; i < hashes[hash].listeners.length; i++)
                        if (hashes[hash].listeners[i].yep)
                            hashes[hash].listeners[i].yep(fragment, parts);
                } else {
                    for (i = 0; i < hashes[hash].listeners.length; i++)
                        if (hashes[hash].listeners[i].nop)
                            hashes[hash].listeners[i].nop(fragment);
                }

            }

            return this;
        }
    });

})();


/* turn.js 4.0.9 | Copyright (c) 2012 Emmanuel Garcia | turnjs.com | turnjs.com/license.txt */
(function (f) {
    function J(a, b, c) {
        if (!c[0] || "object" == typeof c[0]) return b.init.apply(a, c);
        if (b[c[0]]) return b[c[0]].apply(a, Array.prototype.slice.call(c, 1));
        throw p(c[0] + " is not a method or property");
    }
    function o(a, b, c, d) {
        return {
            css: {
                position: "absolute",
                top: a,
                left: b,
                overflow: d || "hidden",
                zIndex: c || "auto"
            }
        }
    }
    function S(a, b, c, d, e) {
        var g = 1 - e,
            k = g * g * g,
            f = e * e * e;
        return j(Math.round(k * a.x + 3 * e * g * g * b.x + 3 * e * e * g * c.x + f * d.x), Math.round(k * a.y + 3 * e * g * g * b.y + 3 * e * e * g * c.y + f * d.y))
    }
    function j(a, b) {
        return {
            x: a,
            y: b
        }
    }
    function F(a,
    b, c) {
        return y && c ? " translate3d(" + a + "px," + b + "px, 0px) " : " translate(" + a + "px, " + b + "px) "
    }
    function G(a) {
        return " rotate(" + a + "deg) "
    }
    function l(a, b) {
        return Object.prototype.hasOwnProperty.call(b, a)
    }
    function T() {
        for (var a = ["Moz", "Webkit", "Khtml", "O", "ms"], b = a.length, c = ""; b--; ) a[b] + "Transform" in document.body.style && (c = "-" + a[b].toLowerCase() + "-");
        return c
    }
    function P(a, b, c, d, e) {
        var g, k = [];
        if ("-webkit-" == w) {
            for (g = 0; g < e; g++) k.push("color-stop(" + d[g][0] + ", " + d[g][1] + ")");
            a.css({
                "background-image": "-webkit-gradient(linear, " + b.x + "% " + b.y + "%," + c.x + "% " + c.y + "%, " + k.join(",") + " )"
            })
        } else {
            var b = {
                x: b.x / 100 * a.width(),
                y: b.y / 100 * a.height()
            }, c = {
                x: c.x / 100 * a.width(),
                y: c.y / 100 * a.height()
            }, f = c.x - b.x;
            g = c.y - b.y;
            var h = Math.atan2(g, f),
                i = h - Math.PI / 2,
                i = Math.abs(a.width() * Math.sin(i)) + Math.abs(a.height() * Math.cos(i)),
                f = Math.sqrt(g * g + f * f),
                c = j(c.x < b.x ? a.width() : 0, c.y < b.y ? a.height() : 0),
                n = Math.tan(h);
            g = -1 / n;
            n = (g * c.x - c.y - n * b.x + b.y) / (g - n);
            c = g * n - g * c.x + c.y;
            b = Math.sqrt(Math.pow(n - b.x, 2) + Math.pow(c - b.y, 2));
            for (g = 0; g < e; g++) k.push(" " + d[g][1] + " " + 100 * (b + f * d[g][0]) / i + "%");
            a.css({
                "background-image": w + "linear-gradient(" + -h + "rad," + k.join(",") + ")"
            })
        }
    }
    function t(a, b, c) {
        a = f.Event(a);
        b.trigger(a, c);
        return a.isDefaultPrevented() ? "prevented" : a.isPropagationStopped() ? "stopped" : ""
    }
    function p(a) {
        function b(a) {
            this.name = "TurnJsError";
            this.message = a
        }
        b.prototype = Error();
        b.prototype.constructor = b;
        return new b(a)
    }
    function D(a) {
        var b = {
            top: 0,
            left: 0
        };
        do b.left += a.offsetLeft, b.top += a.offsetTop;
        while (a = a.offsetParent);
        return b
    }
    var y, w = "",
        K = Math.PI,
        L = K / 2,
        u = "ontouchstart" in window,
        q = u ? {
            down: "touchstart",
            move: "touchmove",
            up: "touchend",
            over: "touchstart",
            out: "touchend"
        } : {
            down: "mousedown",
            move: "mousemove",
            up: "mouseup",
            over: "mouseover",
            out: "mouseout"
        }, s = {
            backward: ["bl", "tl"],
            forward: ["br", "tr"],
            all: "tl bl tr br l r".split(" ")
        }, U = ["single", "double"],
        V = ["ltr", "rtl"],
        W = {
            acceleration: !0,
            display: "double",
            duration: 600,
            page: 1,
            gradients: !0,
            turnCorners: "bl,br",
            when: null
        }, X = {
            cornerSize: 100
        }, h = {
            init: function (a) {
                y = "WebKitCSSMatrix" in window || "MozPerspective" in document.body.style;
                w = T();
                var b, c = this,
                    d = 0,
                    e = this.data(),
                    g = this.children(),
                    a = f.extend({
                        width: this.width(),
                        height: this.height(),
                        direction: this.attr("dir") || this.css("direction") || "ltr"
                    }, W, a);
                e.opts = a;
                e.pageObjs = {};
                e.pages = {};
                e.pageWrap = {};
                e.pageZoom = {};
                e.pagePlace = {};
                e.pageMv = [];
                e.zoom = 1;
                e.totalPages = a.pages || 0;
                e.eventHandlers = {
                    mouseStart: function () {
                        for (var a in e.pages) if (l(a, e.pages) && !1 === i._eventStart.apply(e.pages[a], arguments)) return !1
                    },
                    mouseMove: function () {
                        for (var a in e.pages) l(a, e.pages) && i._eventMove.apply(e.pages[a],
                        arguments)
                    },
                    mouseEnd: function () {
                        for (var a in e.pages) l(a, e.pages) && i._eventEnd.apply(e.pages[a], arguments)
                    },
                    start: function () {
                        return h._start.apply(c, arguments)
                    }
                };
                if (a.when) for (b in a.when) l(b, a.when) && this.bind(b, a.when[b]);
                this.css({
                    position: "relative",
                    width: a.width,
                    height: a.height
                });
                this.turn("display", a.display);
                "" !== a.direction && this.turn("direction", a.direction);
                y && (!u && a.acceleration) && this.transform(F(0, 0, !0));
                for (b = 0; b < g.length; b++) "1" != f(g[b]).attr("ignore") && this.turn("addPage", g[b], ++d);
                f(this).bind(q.down, e.eventHandlers.mouseStart).bind("end", h._end).bind("pressed", h._pressed).bind("released", h._released).bind("flip", h._flip);
                f(this).parent().bind("start", e.eventHandlers.start);
                f(document).bind(q.move, e.eventHandlers.mouseMove).bind(q.up, e.eventHandlers.mouseEnd);
                this.turn("page", a.page);
                e.done = !0;
                return this
            },
            addPage: function (a, b) {
                var c, d = !1,
                    e = this.data(),
                    g = e.totalPages + 1;
                if (e.destroying) return !1;
                if (c = /\bp([0-9]+)\b/.exec(f(a).attr("class"))) b = parseInt(c[1], 10);
                if (b) if (b == g) d = !0;
                else {
                    if (b > g) throw p('Page "' + b + '" cannot be inserted');
                } else b = g, d = !0;
                1 <= b && b <= g && (c = "double" == e.display ? b % 2 ? " odd" : " even" : "", e.done && this.turn("stop"), b in e.pageObjs && h._movePages.call(this, b, 1), d && (e.totalPages = g), e.pageObjs[b] = f(a).css({
                    "float": "left"
                }).addClass("page p" + b + c), h._addPage.call(this, b), h._removeFromDOM.call(this));
                return this
            },
            _addPage: function (a) {
                var b = this.data(),
                    c = b.pageObjs[a];
                if (c) if (h._necessPage.call(this, a)) {
                    if (!b.pageWrap[a]) {
                        b.pageWrap[a] = f("<div/>", {
                            "class": "page-wrapper",
                            page: a,
                            css: {
                                position: "absolute",
                                overflow: "hidden"
                            }
                        });
                        this.append(b.pageWrap[a]);
                        b.pagePlace[a] || (b.pagePlace[a] = a, b.pageObjs[a].appendTo(b.pageWrap[a]));
                        var d = h._pageSize.call(this, a, !0);
                        c.css({
                            width: d.width,
                            height: d.height
                        });
                        b.pageWrap[a].css(d)
                    }
                    b.pagePlace[a] == a && h._makeFlip.call(this, a)
                } else b.pagePlace[a] = 0, b.pageObjs[a] && b.pageObjs[a].remove()
            },
            hasPage: function (a) {
                return l(a, this.data().pageObjs)
            },
            center: function (a) {
                var b = this.data(),
                    c = f(this).turn("size"),
                    d = 0;
                b.noCenter || ("double" == b.display && (a = this.turn("view", a || b.tpage || b.page), "ltr" == b.direction ? a[0] ? a[1] || (d += c.width / 4) : d -= c.width / 4 : a[0] ? a[1] || (d -= c.width / 4) : d += c.width / 4), f(this).css({
                    marginLeft: d
                }));
                return this
            },
            destroy: function () {
                var a = this,
                    b = this.data(),
                    c = "end first flip last pressed released start turning turned zooming missing".split(" ");
                if ("prevented" != t("destroying", this)) {
                    b.destroying = !0;
                    f.each(c, function (b, c) {
                        a.unbind(c)
                    });
                    this.parent().unbind("start", b.eventHandlers.start);
                    for (f(document).unbind(q.move, b.eventHandlers.mouseMove).unbind(q.up,
                    b.eventHandlers.mouseEnd); 0 !== b.totalPages; ) this.turn("removePage", b.totalPages);
                    b.fparent && b.fparent.remove();
                    b.shadow && b.shadow.remove();
                    this.removeData();
                    b = null;
                    return this
                }
            },
            is: function () {
                return "object" == typeof this.data().pages
            },
            zoom: function (a) {
                var b = this.data();
                if ("number" == typeof a) {
                    if (0.0010 > a || 100 < a) throw p(a + " is not a value for zoom");
                    if ("prevented" == t("zooming", this, [a, b.zoom])) return this;
                    var c = this.turn("size"),
                        d = this.turn("view"),
                        e = 1 / b.zoom,
                        g = Math.round(c.width * e * a),
                        c = Math.round(c.height * e * a);
                    b.zoom = a;
                    f(this).turn("stop").turn("size", g, c);
                    b.opts.autoCenter && this.turn("center");
                    h._updateShadow.call(this);
                    for (a = 0; a < d.length; a++) d[a] && b.pageZoom[d[a]] != b.zoom && (this.trigger("zoomed", [d[a], d, b.pageZoom[d[a]], b.zoom]), b.pageZoom[d[a]] = b.zoom);
                    return this
                }
                return b.zoom
            },
            _pageSize: function (a, b) {
                var c = this.data(),
                    d = {};
                if ("single" == c.display) d.width = this.width(), d.height = this.height(), b && (d.top = 0, d.left = 0, d.right = "auto");
                else {
                    var e = this.width() / 2,
                        g = this.height();
                    c.pageObjs[a].hasClass("own-size") ? (d.width = c.pageObjs[a].width(), d.height = c.pageObjs[a].height()) : (d.width = e, d.height = g);
                    if (b) {
                        var f = a % 2;
                        d.top = (g - d.height) / 2;
                        "ltr" == c.direction ? (d[f ? "right" : "left"] = e - d.width, d[f ? "left" : "right"] = "auto") : (d[f ? "left" : "right"] = e - d.width, d[f ? "right" : "left"] = "auto")
                    }
                }
                return d
            },
            _makeFlip: function (a) {
                var b = this.data();
                if (!b.pages[a] && b.pagePlace[a] == a) {
                    var c = "single" == b.display,
                        d = a % 2;
                    b.pages[a] = b.pageObjs[a].css(h._pageSize.call(this, a)).flip({
                        page: a,
                        next: d || c ? a + 1 : a - 1,
                        turn: this
                    }).flip("disable", b.disabled);
                    h._setPageLoc.call(this, a);
                    b.pageZoom[a] = b.zoom
                }
                return b.pages[a]
            },
            _makeRange: function () {
                var a, b;
                if (!(1 > this.data().totalPages)) {
                    b = this.turn("range");
                    for (a = b[0]; a <= b[1]; a++) h._addPage.call(this, a)
                }
            },
            range: function (a) {
                var b, c, d, e = this.data(),
                    a = a || e.tpage || e.page || 1;
                d = h._view.call(this, a);
                if (1 > a || a > e.totalPages) throw p('"' + a + '" is not a valid page');
                d[1] = d[1] || d[0];
                1 <= d[0] && d[1] <= e.totalPages ? (a = Math.floor(2), e.totalPages - d[1] > d[0] ? (b = Math.min(d[0] - 1, a), c = 2 * a - b) : (c = Math.min(e.totalPages - d[1], a), b = 2 * a - c)) : c = b = 5;
                return [Math.max(1, d[0] - b), Math.min(e.totalPages, d[1] + c)]
            },
            _necessPage: function (a) {
                if (0 === a) return !0;
                var b = this.turn("range");
                return this.data().pageObjs[a].hasClass("fixed") || a >= b[0] && a <= b[1]
            },
            _removeFromDOM: function () {
                var a, b = this.data();
                for (a in b.pageWrap) l(a, b.pageWrap) && !h._necessPage.call(this, a) && h._removePageFromDOM.call(this, a)
            },
            _removePageFromDOM: function (a) {
                var b = this.data();
                if (b.pages[a]) {
                    var c = b.pages[a].data();
                    i._moveFoldingPage.call(b.pages[a], !1);
                    c.f && c.f.fwrapper && c.f.fwrapper.remove();
                    b.pages[a].removeData();
                    b.pages[a].remove();
                    delete b.pages[a]
                }
                b.pageObjs[a] && b.pageObjs[a].remove();
                b.pageWrap[a] && (b.pageWrap[a].remove(), delete b.pageWrap[a]);
                h._removeMv.call(this, a);
                delete b.pagePlace[a];
                delete b.pageZoom[a]
            },
            removePage: function (a) {
                var b = this.data();
                if ("*" == a) for (; 0 !== b.totalPages; ) this.turn("removePage", b.totalPages);
                else {
                    if (1 > a || a > b.totalPages) throw p("The page " + a + " doesn't exist");
                    b.pageObjs[a] && (this.turn("stop"), h._removePageFromDOM.call(this, a), delete b.pageObjs[a]);
                    h._movePages.call(this,
                    a, -1);
                    b.totalPages -= 1;
                    b.page > b.totalPages ? (b.page = null, h._fitPage.call(this, b.totalPages)) : (h._makeRange.call(this), this.turn("update"))
                }
                return this
            },
            _movePages: function (a, b) {
                var c, d = this,
                    e = this.data(),
                    g = "single" == e.display,
                    f = function (a) {
                        var c = a + b,
                            f = c % 2,
                            k = f ? " odd " : " even ";
                        e.pageObjs[a] && (e.pageObjs[c] = e.pageObjs[a].removeClass("p" + a + " odd even").addClass("p" + c + k));
                        e.pagePlace[a] && e.pageWrap[a] && (e.pagePlace[c] = c, e.pageWrap[c] = e.pageObjs[c].hasClass("fixed") ? e.pageWrap[a].attr("page", c) : e.pageWrap[a].css(h._pageSize.call(d,
                        c, !0)).attr("page", c), e.pages[a] && (e.pages[c] = e.pages[a].flip("options", {
                            page: c,
                            next: g || f ? c + 1 : c - 1
                        })), b && (delete e.pages[a], delete e.pagePlace[a], delete e.pageZoom[a], delete e.pageObjs[a], delete e.pageWrap[a]))
                    };
                if (0 < b) for (c = e.totalPages; c >= a; c--) f(c);
                else for (c = a; c <= e.totalPages; c++) f(c)
            },
            display: function (a) {
                var b = this.data(),
                    c = b.display;
                if (void 0 === a) return c;
                if (-1 == f.inArray(a, U)) throw p('"' + a + '" is not a value for display');
                switch (a) {
                    case "single":
                        b.pageObjs[0] || (this.turn("stop").css({
                            overflow: "hidden"
                        }),
                    b.pageObjs[0] = f("<div />", {
                        "class": "page p-temporal"
                    }).css({
                        width: this.width(),
                        height: this.height()
                    }).appendTo(this));
                        this.addClass("shadow");
                        break;
                    case "double":
                        b.pageObjs[0] && (this.turn("stop").css({
                            overflow: ""
                        }), b.pageObjs[0].remove(), delete b.pageObjs[0]), this.removeClass("shadow")
                }
                b.display = a;
                c && (a = this.turn("size"), h._movePages.call(this, 1, 0), this.turn("size", a.width, a.height).turn("update"));
                return this
            },
            direction: function (a) {
                var b = this.data();
                if (void 0 === a) return b.direction;
                a = a.toLowerCase();
                if (-1 == f.inArray(a, V)) throw p('"' + a + '" is not a value for direction');
                "rtl" == a && f(this).attr("dir", "ltr").css({
                    direction: "ltr"
                });
                b.direction = a;
                b.done && this.turn("size", f(this).width(), f(this).height());
                return this
            },
            animating: function () {
                return 0 < this.data().pageMv.length
            },
            corner: function () {
                var a, b, c = this.data();
                for (b in c.pages) if (l(b, c.pages) && (a = c.pages[b].flip("corner"))) return a;
                return !1
            },
            data: function () {
                return this.data()
            },
            disable: function (a) {
                var b, c = this.data(),
                    d = this.turn("view");
                c.disabled = void 0 === a || !0 === a;
                for (b in c.pages) l(b, c.pages) && c.pages[b].flip("disable", c.disabled ? !0 : -1 == f.inArray(parseInt(b, 10), d));
                return this
            },
            disabled: function (a) {
                return void 0 === a ? !0 === this.data().disabled : this.turn("disable", a)
            },
            size: function (a, b) {
                if (void 0 === a || void 0 === b) return {
                    width: this.width(),
                    height: this.height()
                };
                this.turn("stop");
                var c, d, e = this.data();
                d = "double" == e.display ? a / 2 : a;
                this.css({
                    width: a,
                    height: b
                });
                e.pageObjs[0] && e.pageObjs[0].css({
                    width: d,
                    height: b
                });
                for (c in e.pageWrap) l(c, e.pageWrap) && (d = h._pageSize.call(this, c, !0), e.pageObjs[c].css({
                    width: d.width,
                    height: d.height
                }), e.pageWrap[c].css(d), e.pages[c] && e.pages[c].css({
                    width: d.width,
                    height: d.height
                }));
                this.turn("resize");
                return this
            },
            resize: function () {
                var a, b = this.data();
                b.pages[0] && (b.pageWrap[0].css({
                    left: -this.width()
                }), b.pages[0].flip("resize", !0));
                for (a = 1; a <= b.totalPages; a++) b.pages[a] && b.pages[a].flip("resize", !0);
                h._updateShadow.call(this);
                b.opts.autoCenter && this.turn("center")
            },
            _removeMv: function (a) {
                var b, c = this.data();
                for (b = 0; b < c.pageMv.length; b++) if (c.pageMv[b] == a) return c.pageMv.splice(b, 1), !0;
                return !1
            },
            _addMv: function (a) {
                var b = this.data();
                h._removeMv.call(this, a);
                b.pageMv.push(a)
            },
            _view: function (a) {
                var b = this.data(),
                    a = a || b.page;
                return "double" == b.display ? a % 2 ? [a - 1, a] : [a, a + 1] : [a]
            },
            view: function (a) {
                var b = this.data(),
                    a = h._view.call(this, a);
                return "double" == b.display ? [0 < a[0] ? a[0] : 0, a[1] <= b.totalPages ? a[1] : 0] : [0 < a[0] && a[0] <= b.totalPages ? a[0] : 0]
            },
            stop: function (a, b) {
                if (this.turn("animating")) {
                    var c, d, e, g = this.data();
                    g.tpage && (g.page = g.tpage, delete g.tpage);
                    for (c = 0; c < g.pageMv.length; c++) g.pageMv[c] && g.pageMv[c] !== a && (e = g.pages[g.pageMv[c]], d = e.data().f.opts, e.flip("hideFoldedPage", b), b || i._moveFoldingPage.call(e, !1), d.force && (d.next = 0 === d.page % 2 ? d.page - 1 : d.page + 1, delete d.force))
                }
                this.turn("update");
                return this
            },
            pages: function (a) {
                var b = this.data();
                if (a) {
                    if (a < b.totalPages) for (var c = b.totalPages; c > a; c--) this.turn("removePage", c);
                    b.totalPages = a;
                    h._fitPage.call(this, b.page);
                    return this
                }
                return b.totalPages
            },
            _missing: function (a) {
                var b = this.data();
                if (!(1 > b.totalPages)) {
                    for (var c = this.turn("range", a), d = [], a = c[0]; a <= c[1]; a++) b.pageObjs[a] || d.push(a);
                    0 < d.length && this.trigger("missing", [d])
                }
            },
            _fitPage: function (a) {
                var b = this.data(),
                    c = this.turn("view", a);
                h._missing.call(this, a);
                if (b.pageObjs[a]) {
                    b.page = a;
                    this.turn("stop");
                    for (var d = 0; d < c.length; d++) c[d] && b.pageZoom[c[d]] != b.zoom && (this.trigger("zoomed", [c[d], c, b.pageZoom[c[d]], b.zoom]), b.pageZoom[c[d]] = b.zoom);
                    h._removeFromDOM.call(this);
                    h._makeRange.call(this);
                    h._updateShadow.call(this);
                    this.trigger("turned", [a, c]);
                    this.turn("update");
                    b.opts.autoCenter && this.turn("center")
                }
            },
            _turnPage: function (a) {
                var b, c, d = this.data(),
                    e = d.pagePlace[a],
                    g = this.turn("view"),
                    k = this.turn("view", a);
                if (d.page != a) {
                    var i = d.page;
                    if ("prevented" == t("turning", this, [a, k])) {
                        i == d.page && -1 != f.inArray(e, d.pageMv) && d.pages[e].flip("hideFoldedPage", !0);
                        return
                    } -1 != f.inArray(1, k) && this.trigger("first"); -1 != f.inArray(d.totalPages, k) && this.trigger("last")
                }
                "single" == d.display ? (b = g[0], c = k[0]) : g[1] && a > g[1] ? (b = g[1], c = k[0]) : g[0] && a < g[0] && (b = g[0], c = k[1]);
                e = d.opts.turnCorners.split(",");
                g = d.pages[b].data().f;
                k = g.opts;
                i = g.point;
                h._missing.call(this, a);
                d.pageObjs[a] && (this.turn("stop"), d.page = a, h._makeRange.call(this), d.tpage = c, k.next != c && (k.next = c, k.force = !0), this.turn("update"), g.point = i, "hard" == g.effect ? "ltr" == d.direction ? d.pages[b].flip("turnPage", a > b ? "r" : "l") : d.pages[b].flip("turnPage", a > b ? "l" : "r") : "ltr" == d.direction ? d.pages[b].flip("turnPage", e[a > b ? 1 : 0]) : d.pages[b].flip("turnPage", e[a > b ? 0 : 1]))
            },
            page: function (a) {
                var b = this.data();
                if (void 0 === a) return b.page;
                if (!b.disabled && !b.destroying) {
                    a = parseInt(a, 10);
                    if (0 < a && a <= b.totalPages) return a != b.page && (!b.done || -1 != f.inArray(a, this.turn("view")) ? h._fitPage.call(this, a) : h._turnPage.call(this, a)), this;
                    throw p("The page " + a + " does not exist");
                }
            },
            next: function () {
                return this.turn("page", Math.min(this.data().totalPages, h._view.call(this, this.data().page).pop() + 1))
            },
            previous: function () {
                return this.turn("page", Math.max(1, h._view.call(this, this.data().page).shift() - 1))
            },
            peel: function (a,
            b) {
                var c = this.data(),
                    d = this.turn("view"),
                    b = void 0 === b ? !0 : !0 === b;
                !1 === a ? this.turn("stop", null, b) : "single" == c.display ? c.pages[c.page].flip("peel", a, b) : (d = "ltr" == c.direction ? -1 != a.indexOf("l") ? d[0] : d[1] : -1 != a.indexOf("l") ? d[1] : d[0], c.pages[d] && c.pages[d].flip("peel", a, b));
                return this
            },
            _addMotionPage: function () {
                var a = f(this).data().f.opts,
                    b = a.turn;
                b.data();
                h._addMv.call(b, a.page)
            },
            _start: function (a, b, c) {
                var d = b.turn.data(),
                    e = d.pageZoom[b.page];
                a.isDefaultPrevented() || (e && e != d.zoom && (b.turn.trigger("zoomed", [b.page, b.turn.turn("view", b.page), e, d.zoom]), d.pageZoom[b.page] = d.zoom), "single" == d.display && c && ("l" == c.charAt(1) && "ltr" == d.direction || "r" == c.charAt(1) && "rtl" == d.direction ? (b.next = b.next < b.page ? b.next : b.page - 1, b.force = !0) : b.next = b.next > b.page ? b.next : b.page + 1), h._addMotionPage.call(a.target));
                h._updateShadow.call(b.turn)
            },
            _end: function (a, b, c) {
                f(a.target).data();
                var a = b.turn,
                    d = a.data();
                if (c) {
                    if (c = d.tpage || d.page, c == b.next || c == b.page) delete d.tpage, h._fitPage.call(a, c || b.next, !0)
                } else h._removeMv.call(a,
                b.page), h._updateShadow.call(a), a.turn("update")
            },
            _pressed: function (a) {
                var a = f(a.target).data().f,
                    b = a.opts.turn;
                b.data().mouseAction = !0;
                b.turn("update");
                return a.time = (new Date).getTime()
            },
            _released: function (a, b) {
                var c;
                c = f(a.target);
                var d = c.data().f,
                    e = d.opts.turn,
                    g = e.data();
                c = "single" == g.display ? "br" == b.corner || "tr" == b.corner ? b.x < c.width() / 2 : b.x > c.width() / 2 : 0 > b.x || b.x > c.width();
                if (200 > (new Date).getTime() - d.time || c) a.preventDefault(), h._turnPage.call(e, d.opts.next);
                g.mouseAction = !1
            },
            _flip: function (a) {
                a.stopPropagation();
                a = f(a.target).data().f.opts;
                a.turn.trigger("turn", [a.next]);
                a.turn.data().opts.autoCenter && a.turn.turn("center", a.next)
            },
            calculateZ: function (a) {
                var b, c, d, e, g = this,
                    f = this.data();
                b = this.turn("view");
                var i = b[0] || b[1],
                    h = a.length - 1,
                    j = {
                        pageZ: {},
                        partZ: {},
                        pageV: {}
                    }, n = function (a) {
                        a = g.turn("view", a);
                        a[0] && (j.pageV[a[0]] = !0);
                        a[1] && (j.pageV[a[1]] = !0)
                    };
                for (b = 0; b <= h; b++) c = a[b], d = f.pages[c].data().f.opts.next, e = f.pagePlace[c], n(c), n(d), c = f.pagePlace[d] == d ? d : c, j.pageZ[c] = f.totalPages - Math.abs(i - c), j.partZ[e] = 2 * f.totalPages - h + b;
                return j
            },
            update: function () {
                var a, b = this.data();
                if (this.turn("animating") && 0 !== b.pageMv[0]) {
                    var c, d = this.turn("calculateZ", b.pageMv),
                        e = this.turn("corner"),
                        g = this.turn("view"),
                        i = this.turn("view", b.tpage);
                    for (a in b.pageWrap) if (l(a, b.pageWrap) && (c = b.pageObjs[a].hasClass("fixed"), b.pageWrap[a].css({
                        display: d.pageV[a] || c ? "" : "none",
                        zIndex: (b.pageObjs[a].hasClass("hard") ? d.partZ[a] : d.pageZ[a]) || (c ? -1 : 0)
                    }), c = b.pages[a])) c.flip("z", d.partZ[a] || null), d.pageV[a] && c.flip("resize"), b.tpage ? c.flip("hover", !1).flip("disable", -1 == f.inArray(parseInt(a, 10), b.pageMv) && a != i[0] && a != i[1]) : c.flip("hover", !1 === e).flip("disable", a != g[0] && a != g[1])
                } else for (a in b.pageWrap) l(a, b.pageWrap) && (d = h._setPageLoc.call(this, a), b.pages[a] && b.pages[a].flip("disable", b.disabled || 1 != d).flip("hover", !0).flip("z", null));
                return this
            },
            _updateShadow: function () {
                var a, b, c = this.data(),
                    d = this.width(),
                    e = this.height(),
                    g = "single" == c.display ? d : d / 2;
                a = this.turn("view");
                c.shadow || (c.shadow = f("<div />", {
                    "class": "shadow",
                    css: o(0, 0, 0).css
                }).appendTo(this));
                for (var i = 0; i < c.pageMv.length && a[0] && a[1]; i++) a = this.turn("view", c.pages[c.pageMv[i]].data().f.opts.next), b = this.turn("view", c.pageMv[i]), a[0] = a[0] && b[0], a[1] = a[1] && b[1];
                switch (a[0] ? a[1] ? 3 : "ltr" == c.direction ? 2 : 1 : "ltr" == c.direction ? 1 : 2) {
                    case 1:
                        c.shadow.css({
                            width: g,
                            height: e,
                            top: 0,
                            left: g
                        });
                        break;
                    case 2:
                        c.shadow.css({
                            width: g,
                            height: e,
                            top: 0,
                            left: 0
                        });
                        break;
                    case 3:
                        c.shadow.css({
                            width: d,
                            height: e,
                            top: 0,
                            left: 0
                        })
                }
            },
            _setPageLoc: function (a) {
                var b = this.data(),
                    c = this.turn("view"),
                    d = 0;
                if (a == c[0] || a == c[1]) d = 1;
                else if ("single" == b.display && a == c[0] + 1 || "double" == b.display && a == c[0] - 2 || a == c[1] + 2) d = 2;
                if (!this.turn("animating")) switch (d) {
                    case 1:
                        b.pageWrap[a].css({
                            zIndex: b.totalPages,
                            display: ""
                        });
                        break;
                    case 2:
                        b.pageWrap[a].css({
                            zIndex: b.totalPages - 1,
                            display: ""
                        });
                        break;
                    case 0:
                        b.pageWrap[a].css({
                            zIndex: 0,
                            display: b.pageObjs[a].hasClass("fixed") ? "" : "none"
                        })
                }
                return d
            },
            options: function (a) {
                if (void 0 === a) return this.data().opts;
                var b = this.data();
                f.extend(b.opts, a);
                a.pages && this.turn("pages", a.pages);
                a.page && this.turn("page", a.page);
                a.display && this.turn("display", a.display);
                a.direction && this.turn("direction", a.direction);
                a.width && a.height && this.turn("size", a.width, a.height);
                if (a.when) for (var c in a.when) l(c, a.when) && this.unbind(c).bind(c, a.when[c]);
                return this
            },
            version: function () {
                return "4.0.9"
            }
        }, i = {
            init: function (a) {
                this.data({
                    f: {
                        disabled: !1,
                        hover: !1,
                        effect: this.hasClass("hard") ? "hard" : "sheet"
                    }
                });
                this.flip("options", a);
                i._addPageWrapper.call(this);
                return this
            },
            setData: function (a) {
                var b = this.data();
                b.f = f.extend(b.f, a);
                return this
            },
            options: function (a) {
                var b = this.data().f;
                return a ? (i.setData.call(this, {
                    opts: f.extend({}, b.opts || X, a)
                }), this) : b.opts
            },
            z: function (a) {
                var b = this.data().f;
                b.opts["z-index"] = a;
                b.fwrapper && b.fwrapper.css({
                    zIndex: a || parseInt(b.parent.css("z-index"), 10) || 0
                });
                return this
            },
            _cAllowed: function () {
                var a = this.data().f,
                    b = a.opts.page,
                    c = a.opts.turn.data(),
                    d = b % 2;
                return "hard" == a.effect ? "ltr" == c.direction ? [d ? "r" : "l"] : [d ? "l" : "r"] : "single" == c.display ? 1 == b ? "ltr" == c.direction ? s.forward : s.backward : b == c.totalPages ? "ltr" == c.direction ? s.backward : s.forward : s.all : "ltr" == c.direction ? s[d ? "forward" : "backward"] : s[d ? "backward" : "forward"]
            },
            _cornerActivated: function (a) {
                var b = this.data().f,
                    c = this.width(),
                    d = this.height(),
                    a = {
                        x: a.x,
                        y: a.y,
                        corner: ""
                    }, e = b.opts.cornerSize;
                if (0 >= a.x || 0 >= a.y || a.x >= c || a.y >= d) return !1;
                var g = i._cAllowed.call(this);
                switch (b.effect) {
                    case "hard":
                        if (a.x > c - e) a.corner = "r";
                        else if (a.x < e) a.corner = "l";
                        else return !1;
                        break;
                    case "sheet":
                        if (a.y < e) a.corner += "t";
                        else if (a.y >= d - e) a.corner += "b";
                        else return !1;
                        if (a.x <= e) a.corner += "l";
                        else if (a.x >= c - e) a.corner += "r";
                        else return !1
                }
                return !a.corner || -1 == f.inArray(a.corner, g) ? !1 : a
            },
            _isIArea: function (a) {
                var b = this.data().f.parent.offset(),
                    a = u && a.originalEvent ? a.originalEvent.touches[0] : a;
                return i._cornerActivated.call(this, {
                    x: a.pageX - b.left,
                    y: a.pageY - b.top
                })
            },
            _c: function (a, b) {
                b = b || 0;
                switch (a) {
                    case "tl":
                        return j(b, b);
                    case "tr":
                        return j(this.width() - b, b);
                    case "bl":
                        return j(b, this.height() - b);
                    case "br":
                        return j(this.width() - b, this.height() - b);
                    case "l":
                        return j(b, 0);
                    case "r":
                        return j(this.width() - b, 0)
                }
            },
            _c2: function (a) {
                switch (a) {
                    case "tl":
                        return j(2 * this.width(), 0);
                    case "tr":
                        return j(-this.width(), 0);
                    case "bl":
                        return j(2 * this.width(), this.height());
                    case "br":
                        return j(-this.width(), this.height());
                    case "l":
                        return j(2 * this.width(), 0);
                    case "r":
                        return j(-this.width(), 0)
                }
            },
            _foldingPage: function () {
                var a = this.data().f;
                if (a) {
                    var b = a.opts;
                    if (b.turn) return a = b.turn.data(), "single" == a.display ? a.pageObjs[b.next] ? a.pageObjs[0] : null : a.pageObjs[b.next]
                }
            },
            _backGradient: function () {
                var a = this.data().f,
                    b = a.opts.turn.data();
                if ((b = b.opts.gradients && ("single" == b.display || 2 != a.opts.page && a.opts.page != b.totalPages - 1)) && !a.bshadow) a.bshadow = f("<div/>", o(0, 0, 1)).css({
                    position: "",
                    width: this.width(),
                    height: this.height()
                }).appendTo(a.parent);
                return b
            },
            type: function () {
                return this.data().f.effect
            },
            resize: function (a) {
                var b = this.data().f,
                    c = b.opts.turn.data(),
                    d = this.width(),
                    e = this.height();
                switch (b.effect) {
                    case "hard":
                        a && (b.wrapper.css({
                            width: d,
                            height: e
                        }), b.fpage.css({
                            width: d,
                            height: e
                        }), c.opts.gradients && (b.ashadow.css({
                            width: d,
                            height: e
                        }), b.bshadow.css({
                            width: d,
                            height: e
                        })));
                        break;
                    case "sheet":
                        a && (a = Math.round(Math.sqrt(Math.pow(d, 2) + Math.pow(e, 2))), b.wrapper.css({
                            width: a,
                            height: a
                        }), b.fwrapper.css({
                            width: a,
                            height: a
                        }).children(":first-child").css({
                            width: d,
                            height: e
                        }), b.fpage.css({
                            width: d,
                            height: e
                        }), c.opts.gradients && b.ashadow.css({
                            width: d,
                            height: e
                        }), i._backGradient.call(this) && b.bshadow.css({
                            width: d,
                            height: e
                        })), b.parent.is(":visible") && (c = D(b.parent[0]), b.fwrapper.css({
                            top: c.top,
                            left: c.left
                        }), c = D(b.opts.turn[0]), b.fparent.css({
                            top: -c.top,
                            left: -c.left
                        })), this.flip("z", b.opts["z-index"])
                }
            },
            _addPageWrapper: function () {
                var a = this.data().f,
                    b = a.opts.turn.data(),
                    c = this.parent();
                a.parent = c;
                if (!a.wrapper) switch (a.effect) {
                    case "hard":
                        var d = {};
                        d[w + "transform-style"] = "preserve-3d";
                        d[w + "backface-visibility"] = "hidden";
                        a.wrapper = f("<div/>", o(0, 0, 2)).css(d).appendTo(c).prepend(this);
                        a.fpage = f("<div/>", o(0, 0, 1)).css(d).appendTo(c);
                        b.opts.gradients && (a.ashadow = f("<div/>", o(0, 0, 0)).hide().appendTo(c), a.bshadow = f("<div/>", o(0, 0, 0)));
                        break;
                    case "sheet":
                        var d = this.width(),
                        e = this.height();
                        Math.round(Math.sqrt(Math.pow(d,
                    2) + Math.pow(e, 2)));
                        a.fparent = a.opts.turn.data().fparent;
                        a.fparent || (d = f("<div/>", {
                            css: {
                                "pointer-events": "none"
                            }
                        }).hide(), d.data().flips = 0, d.css(o(0, 0, "auto", "visible").css).appendTo(a.opts.turn), a.opts.turn.data().fparent = d, a.fparent = d);
                        this.css({
                            position: "absolute",
                            top: 0,
                            left: 0,
                            bottom: "auto",
                            right: "auto"
                        });
                        a.wrapper = f("<div/>", o(0, 0, this.css("z-index"))).appendTo(c).prepend(this);
                        a.fwrapper = f("<div/>", o(c.offset().top, c.offset().left)).hide().appendTo(a.fparent);
                        a.fpage = f("<div/>", o(0, 0, 0, "visible")).css({
                            cursor: "default"
                        }).appendTo(a.fwrapper);
                        a.fpage.addClass('page-corner'); //corners
                        b.opts.gradients && (a.ashadow = f("<div/>", o(0, 0, 1)).appendTo(a.fpage));
                        i.setData.call(this, a)
                }
                i.resize.call(this, !0)
            },
            _fold: function (a) {
                var b = this.data().f,
                    c = b.opts.turn.data(),
                    d = i._c.call(this, a.corner),
                    e = this.width(),
                    g = this.height();
                switch (b.effect) {
                    case "hard":
                        a.x = "l" == a.corner ? Math.min(Math.max(a.x, 0), 2 * e) : Math.max(Math.min(a.x, e), -e);
                        var f, h, r, l, n, o = c.totalPages,
                        p = b.opts["z-index"] || o,
                        s = {
                            overflow: "visible"
                        }, z = d.x ? (d.x - a.x) / e : a.x / e,
                        q = 90 * z,
                        t = 90 > q;
                        switch (a.corner) {
                            case "l":
                                l = "0% 50%";
                                n = "100% 50%";
                                t ? (f = 0, h = 0 < b.opts.next - 1, r = 1) : (f = "100%", h = b.opts.page + 1 < o, r = 0);
                                break;
                            case "r":
                                l = "100% 50%", n = "0% 50%", q = -q, e = -e, t ? (f = 0, h = b.opts.next + 1 < o, r = 0) : (f = "-100%", h = 1 != b.opts.page, r = 1)
                        }
                        s[w + "perspective-origin"] = n;
                        b.wrapper.transform("rotateY(" + q + "deg)translate3d(0px, 0px, " + (this.attr("depth") || 0) + "px)", n);
                        b.fpage.transform("translateX(" + e + "px) rotateY(" + (180 + q) + "deg)", l);
                        b.parent.css(s);
                        t ? (z = -z + 1, b.wrapper.css({
                            zIndex: p + 1
                        }), b.fpage.css({
                            zIndex: p
                        })) : (z -= 1, b.wrapper.css({
                            zIndex: p
                        }), b.fpage.css({
                            zIndex: p + 1
                        }));
                        c.opts.gradients && (h ? b.ashadow.css({
                            display: "",
                            left: f,
                            backgroundColor: "rgba(0,0,0," + 0.5 * z + ")"
                        }).transform("rotateY(0deg)") : b.ashadow.hide(), b.bshadow.css({
                            opacity: -z + 1
                        }), t ? b.bshadow.parent()[0] != b.wrapper[0] && b.bshadow.appendTo(b.wrapper) : b.bshadow.parent()[0] != b.fpage[0] && b.bshadow.appendTo(b.fpage), P(b.bshadow, j(100 * r, 0), j(100 * (-r + 1), 0), [
                        [0, "rgba(0,0,0,0.3)"],
                        [1, "rgba(0,0,0,0)"]
                    ], 2));
                        break;
                    case "sheet":
                        var u = this,
                        H = 0,
                        y, A, B, M, x, N, D, v = j(0, 0),
                        Q = j(0, 0),
                        m = j(0, 0),
                        J = i._foldingPage.call(this);
                        Math.tan(0);
                        var O = c.opts.acceleration,
                        R = b.wrapper.height(),
                        E = "t" == a.corner.substr(0, 1),
                        C = "l" == a.corner.substr(1, 1),
                        I = function () {
                            var b = j(d.x ? d.x - a.x : a.x, d.y ? d.y - a.y : a.y),
                                f = j(C ? e - b.x / 2 : a.x + b.x / 2, b.y / 2),
                                h = L - Math.atan2(b.y, b.x),
                                k = h - Math.atan2(f.y, f.x),
                                k = Math.max(0, Math.sin(k) * Math.sqrt(Math.pow(f.x, 2) + Math.pow(f.y, 2)));
                            H = 180 * (h / K);
                            m = j(k * Math.sin(h), k * Math.cos(h));
                            if (h > L && (m.x += Math.abs(m.y * b.y / b.x), m.y = 0, Math.round(m.x * Math.tan(K - h)) < g)) return a.y = Math.sqrt(Math.pow(g, 2) + 2 * f.x * b.x), E && (a.y = g - a.y), I();
                            if (h > L && (b = K - h, f = R - g / Math.sin(b), v = j(Math.round(f * Math.cos(b)), Math.round(f * Math.sin(b))), C && (v.x = -v.x), E)) v.y = -v.y;
                            y = Math.round(m.y / Math.tan(h) + m.x);
                            b = e - y;
                            f = b * Math.cos(2 * h);
                            k = b * Math.sin(2 * h);
                            Q = j(Math.round(C ? b - f : y + f), Math.round(E ? k : g - k));
                            if (c.opts.gradients && (x = b * Math.sin(h), b = i._c2.call(u, a.corner), b = Math.sqrt(Math.pow(b.x - a.x, 2) + Math.pow(b.y - a.y, 2)) / e, D = Math.sin(L * (1 < b ? 2 - b : b)), N = Math.min(b, 1), M = 100 < x ? (x - 100) / x : 0, A = j(100 * (x * Math.sin(h) / e), 100 * (x * Math.cos(h) / g)), i._backGradient.call(u) && (B = j(100 * (1.2 * x * Math.sin(h) / e), 100 * (1.2 * x * Math.cos(h) / g)), C || (B.x = 100 - B.x), !E))) B.y = 100 - B.y;
                            m.x = Math.round(m.x);
                            m.y = Math.round(m.y);
                            return !0
                        };
                        f = function (a, d, f, h) {
                            var k = ["0", "auto"],
                            n = (e - R) * f[0] / 100,
                            m = (g - R) * f[1] / 100,
                            d = {
                                left: k[d[0]],
                                top: k[d[1]],
                                right: k[d[2]],
                                bottom: k[d[3]]
                            }, k = {}, l = 90 != h && -90 != h ? C ? -1 : 1 : 0,
                            r = f[0] + "% " + f[1] + "%";
                            u.css(d).transform(G(h) + F(a.x + l, a.y, O), r);
                            b.fpage.css(d).transform(G(h) + F(a.x + Q.x - v.x - e * f[0] / 100, a.y + Q.y - v.y - g * f[1] / 100, O) + G((180 / h - 2) * h), r);
                            b.wrapper.transform(F(-a.x + n - l, -a.y + m, O) + G(-h), r);
                            b.fwrapper.transform(F(-a.x + v.x + n, -a.y + v.y + m, O) + G(-h), r);
                            c.opts.gradients && (f[0] && (A.x = 100 - A.x), f[1] && (A.y = 100 - A.y), k["box-shadow"] = "0 0 20px rgba(0,0,0," + 0.5 * D + ")", J.css(k), P(b.ashadow, j(C ? 100 : 0, E ? 0 : 100), j(A.x, A.y), [
                            [M, "rgba(0,0,0,0)"],
                            [0.8 * (1 - M) + M, "rgba(0,0,0," + 0.2 * N + ")"],
                            [1, "rgba(255,255,255," + 0.2 * N + ")"]
                        ], 3, 0), i._backGradient.call(u) && P(b.bshadow, j(C ? 0 : 100, E ? 0 : 100), j(B.x, B.y), [
                            [0.6, "rgba(0,0,0,0)"],
                            [0.8, "rgba(0,0,0," + 0.3 * N + ")"],
                            [1, "rgba(0,0,0,0)"]
                        ], 3))
                        };
                        switch (a.corner) {
                            case "tl":
                                a.x = Math.max(a.x, 1);
                                I();
                                f(m, [1, 0, 0, 1], [100,
                        0], H);
                                break;
                            case "tr":
                                a.x = Math.min(a.x, e - 1);
                                I();
                                f(j(-m.x, m.y), [0, 0, 0, 1], [0, 0], -H);
                                break;
                            case "bl":
                                a.x = Math.max(a.x, 1);
                                I();
                                f(j(m.x, -m.y), [1, 1, 0, 0], [100, 100], -H);
                                break;
                            case "br":
                                a.x = Math.min(a.x, e - 1), I(), f(j(-m.x, -m.y), [0, 1, 1, 0], [0, 100], H)
                        }
                }
                b.point = a
            },
            _moveFoldingPage: function (a) {
                var b = this.data().f;
                if (b) {
                    var c = b.opts.turn,
                        d = c.data(),
                        e = d.pagePlace;
                    a ? (d = b.opts.next, e[d] != b.opts.page && (b.folding && i._moveFoldingPage.call(this, !1), i._foldingPage.call(this).appendTo(b.fpage), e[d] = b.opts.page, b.folding = d),
                    c.turn("update")) : b.folding && (d.pages[b.folding] ? (c = d.pages[b.folding].data().f, d.pageObjs[b.folding].appendTo(c.wrapper)) : d.pageWrap[b.folding] && d.pageObjs[b.folding].appendTo(d.pageWrap[b.folding]), b.folding in e && (e[b.folding] = b.folding), delete b.folding)
                }
            },
            _showFoldedPage: function (a, b) {
                var c = i._foldingPage.call(this),
                    d = this.data(),
                    e = d.f,
                    f = e.visible;
                if (c) {
                    if (!f || !e.point || e.point.corner != a.corner) if (c = "hover" == e.status || "peel" == e.status || e.opts.turn.data().mouseAction ? a.corner : null, f = !1, "prevented" == t("start", this, [e.opts, c])) return !1;
                    if (b) {
                        var h = this,
                            d = e.point && e.point.corner == a.corner ? e.point : i._c.call(this, a.corner, 1);
                        this.animatef({
                            from: [d.x, d.y],
                            to: [a.x, a.y],
                            duration: 500,
                            frame: function (b) {
                                a.x = Math.round(b[0]);
                                a.y = Math.round(b[1]);
                                i._fold.call(h, a)
                            }
                        })
                    } else i._fold.call(this, a), d.effect && !d.effect.turning && this.animatef(!1);
                    if (!f) switch (e.effect) {
                        case "hard":
                            e.visible = !0;
                            i._moveFoldingPage.call(this, !0);
                            e.fpage.show();
                            e.opts.shadows && e.bshadow.show();
                            break;
                        case "sheet":
                            e.visible = !0, e.fparent.show().data().flips++,
                        i._moveFoldingPage.call(this, !0), e.fwrapper.show(), e.bshadow && e.bshadow.show()
                    }
                    return !0
                }
                return !1
            },
            hide: function () {
                var a = this.data().f,
                    b = a.opts.turn.data(),
                    c = i._foldingPage.call(this);
                switch (a.effect) {
                    case "hard":
                        b.opts.gradients && (a.bshadowLoc = 0, a.bshadow.remove(), a.ashadow.hide());
                        a.wrapper.transform("");
                        a.fpage.hide();
                        break;
                    case "sheet":
                        0 === --a.fparent.data().flips && a.fparent.hide(), this.css({
                            left: 0,
                            top: 0,
                            right: "auto",
                            bottom: "auto"
                        }).transform(""), a.wrapper.transform(""), a.fwrapper.hide(), a.bshadow && a.bshadow.hide(), c.transform("")
                }
                a.visible = !1;
                return this
            },
            hideFoldedPage: function (a) {
                var b = this.data().f;
                if (b.point) {
                    var c = this,
                        d = b.point,
                        e = function () {
                            b.point = null;
                            b.status = "";
                            c.flip("hide");
                            c.trigger("end", [b.opts, !1])
                        };
                    if (a) {
                        var f = i._c.call(this, d.corner),
                            a = "t" == d.corner.substr(0, 1) ? Math.min(0, d.y - f.y) / 2 : Math.max(0, d.y - f.y) / 2,
                            h = j(d.x, d.y + a),
                            l = j(f.x, f.y - a);
                        this.animatef({
                            from: 0,
                            to: 1,
                            frame: function (a) {
                                a = S(d, h, l, f, a);
                                d.x = a.x;
                                d.y = a.y;
                                i._fold.call(c, d)
                            },
                            complete: e,
                            duration: 800,
                            hiding: !0
                        })
                    } else this.animatef(!1),
                    e()
                }
            },
            turnPage: function (a) {
                var b = this,
                    c = this.data().f,
                    d = c.opts.turn.data(),
                    a = {
                        corner: c.corner ? c.corner.corner : a || i._cAllowed.call(this)[0]
                    }, e = c.point || i._c.call(this, a.corner, c.opts.turn ? d.opts.elevation : 0),
                    f = i._c2.call(this, a.corner);
                this.trigger("flip").animatef({
                    from: 0,
                    to: 1,
                    frame: function (c) {
                        c = S(e, e, f, f, c);
                        a.x = c.x;
                        a.y = c.y;
                        i._showFoldedPage.call(b, a)
                    },
                    complete: function () {
                        b.trigger("end", [c.opts, !0])
                    },
                    duration: d.opts.duration,
                    turning: !0
                });
                c.corner = null
            },
            moving: function () {
                return "effect" in this.data()
            },
            isTurning: function () {
                return this.flip("moving") && this.data().effect.turning
            },
            corner: function () {
                return this.data().f.corner
            },
            _eventStart: function (a) {
                var b = this.data().f,
                    c = b.opts.turn;
                if (!b.disabled && !this.flip("isTurning") && b.opts.page == c.data().pagePlace[b.opts.page]) {
                    b.corner = i._isIArea.call(this, a);
                    if (b.corner && i._foldingPage.call(this)) return this.trigger("pressed", [b.point]), i._showFoldedPage.call(this, b.corner), !1;
                    b.corner = null
                }
            },
            _eventMove: function (a) {
                var b = this.data().f;
                if (!b.disabled) if (a = u ? a.originalEvent.touches : [a], b.corner) {
                    var c = b.parent.offset();
                    b.corner.x = a[0].pageX - c.left;
                    b.corner.y = a[0].pageY - c.top;
                    i._showFoldedPage.call(this, b.corner)
                } else if (b.hover && !this.data().effect && this.is(":visible")) if (a = i._isIArea.call(this, a[0])) {
                    if ("sheet" == b.effect && 2 == a.corner.length || "hard" == b.effect) b.status = "hover", b = i._c.call(this, a.corner, b.opts.cornerSize / 2), a.x = b.x, a.y = b.y, i._showFoldedPage.call(this, a, !0)
                } else "hover" == b.status && (b.status = "", i.hideFoldedPage.call(this, !0))
            },
            _eventEnd: function () {
                var a = this.data().f,
                    b = a.corner;
                !a.disabled && b && "prevented" != t("released", this, [a.point || b]) && i.hideFoldedPage.call(this, !0);
                a.corner = null
            },
            disable: function (a) {
                i.setData.call(this, {
                    disabled: a
                });
                return this
            },
            hover: function (a) {
                i.setData.call(this, {
                    hover: a
                });
                return this
            },
            peel: function (a, b) {
                var c = this.data().f;
                if (a) {
                    if (-1 == f.inArray(a, s.all)) throw p("Corner " + a + " is not permitted");
                    if (-1 != f.inArray(a, i._cAllowed.call(this))) {
                        var d = i._c.call(this, a, c.opts.cornerSize / 2);
                        c.status = "peel";
                        i._showFoldedPage.call(this, {
                            corner: a,
                            x: d.x,
                            y: d.y
                        }, b)
                    }
                } else c.status = "", i.hideFoldedPage.call(this, b);
                return this
            }
        };
    window.requestAnim = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (a) {
        window.setTimeout(a, 1E3 / 60)
    };
    f.extend(f.fn, {
        flip: function () {
            return J(f(this[0]), i, arguments)
        },
        turn: function () {
            return J(f(this[0]), h, arguments)
        },
        transform: function (a, b) {
            var c = {};
            b && (c[w + "transform-origin"] = b);
            c[w + "transform"] = a;
            return this.css(c)
        },
        animatef: function (a) {
            var b = this.data();
            b.effect && b.effect.stop();
            if (a) {
                a.to.length || (a.to = [a.to]);
                a.from.length || (a.from = [a.from]);
                for (var c = [], d = a.to.length, e = !0, g = this, h = (new Date).getTime(), i = function () {
                    if (b.effect && e) {
                        for (var f = [], j = Math.min(a.duration, (new Date).getTime() - h), l = 0; l < d; l++) f.push(b.effect.easing(1, j, a.from[l], c[l], a.duration));
                        a.frame(d == 1 ? f[0] : f);
                        if (j == a.duration) {
                            delete b.effect;
                            g.data(b);
                            a.complete && a.complete()
                        } else window.requestAnim(i)
                    }
                }, j = 0; j < d; j++) c.push(a.to[j] - a.from[j]);
                b.effect = f.extend({
                    stop: function () {
                        e = false
                    },
                    easing: function (a, b, c, d, e) {
                        return d * Math.sqrt(1 - (b = b / e - 1) * b) + c
                    }
                }, a);
                this.data(b);
                i()
            } else delete b.effect
        }
    });
    f.isTouch = u;
    f.mouseEvents = q;
    f.cssPrefix = T;
    f.cssTransitionEnd = function () {
        var a, b = document.createElement("fakeelement"),
            c = {
                transition: "transitionend",
                OTransition: "oTransitionEnd",
                MSTransition: "transitionend",
                MozTransition: "transitionend",
                WebkitTransition: "webkitTransitionEnd"
            };
        for (a in c) if (void 0 !== b.style[a]) return c[a]
    };
    f.findPos = D
})(jQuery);

/* turn.js 4.0.9 | Copyright (c) 2012 Emmanuel Garcia | turnjs.com | turnjs.com/license.txt */
(function (f) {
    function q(a, b) {
        return a[0] == b[0] ? !1 : a.attr("page") ? !0 : a.parent()[0] ? q(a.parent(), b) : !1
    }
    function t(a) {
        function b(a) {
            this.name = "TurnJsError";
            this.message = a
        }
        b.prototype = Error();
        b.prototype.constructor = b;
        return new b(a)
    }
    function s(a, b, d) {
        return p && d ? " translate3d(" + a + "px," + b + "px, 0px) " : " translate(" + a + "px, " + b + "px) "
    }
    function u(a, b) {
        return p && b ? " scale3d(" + a + ", " + a + ", 1) " : " scale(" + a + ") "
    }
    function h(a, b) {
        return {
            x: a,
            y: b
        }
    }
    function m(a, b) {
        return function () {
            return a.apply(b, arguments)
        }
    }
    var p,
    v = {
        max: 2,
        flipbook: null,
        easeFunction: "ease-in-out",
        duration: 500,
        when: {}
    }, j = {
        init: function (a) {
            var b = this,
                d = this.data(),
                a = f.extend({}, v, a);
            if (!a.flipbook || !a.flipbook.turn("is")) throw t("options.flipbook is required");
            p = "WebKitCSSMatrix" in window || "MozPerspective" in document.body.style;
            if ("function" != typeof a.max) {
                var e = a.max;
                a.max = function () {
                    return e
                }
            }
            d.zoom = {
                opts: a,
                axis: h(0, 0),
                scrollPos: h(0, 0),
                eventQueue: [],
                mouseupEvent: function () {
                    return j._eMouseUp.apply(b, arguments)
                },
                eventTouchStart: m(j._eTouchStart,
                b),
                eventTouchMove: m(j._eTouchMove, b),
                eventTouchEnd: m(j._eTouchEnd, b),
                flipbookEvents: {
                    zooming: m(j._eZoom, b),
                    pressed: m(j._ePressed, b),
                    released: m(j._eReleased, b),
                    start: m(j._eStart, b),
                    turning: m(j._eTurning, b),
                    turned: m(j._eTurned, b),
                    destroying: m(j._eDestroying, b)
                }
            };
            for (var c in a.when) Object.prototype.hasOwnProperty.call(a.when, c) && this.bind("zoom." + c, a.when[c]);
            for (c in d.zoom.flipbookEvents) Object.prototype.hasOwnProperty.call(d.zoom.flipbookEvents, c) && a.flipbook.bind(c, d.zoom.flipbookEvents[c]);
            this.css({
                position: "relative",
                overflow: "hidden"
            });
            f.isTouch ? (a.flipbook.bind("touchstart", d.zoom.eventTouchStart).bind("touchmove", d.zoom.eventTouchMove).bind("touchend", d.zoom.eventTouchEnd), this.bind("touchstart", j._tap)) : this.mousedown(j._mousedown).click(j._tap)
        },
        _tap: function (a) {
            var b = f(this),
                d = b.data().zoom;
            !d.draggingCorner && !d.dragging && q(f(a.target), b) && (j._addEvent.call(b, "tap", a), (a = j._eventSeq.call(b)) && b.trigger(a))
        },
        _addEvent: function (a, b) {
            var d = this.data().zoom,
                e = (new Date).getTime();
            d.eventQueue.push({
                name: a,
                timestamp: e,
                event: b
            });
            10 < d.eventQueue.length && d.eventQueue.splice(0, 1)
        },
        _eventSeq: function () {
            var a = this.data().zoom.eventQueue,
                b = a.length - 1;
            if (0 < b && "tap" == a[b].name && "tap" == a[b - 1].name && a[b].event.pageX == a[b - 1].event.pageX && a[b].event.pageY == a[b - 1].event.pageY && 200 > a[b].timestamp - a[b - 1].timestamp && 50 < a[b].timestamp - a[b - 1].timestamp) return f.extend(a[b].event, {
                type: "zoom.doubleTap"
            });
            if ("tap" == a[b].name) return f.extend(a[b].event, {
                type: "zoom.tap"
            })
        },
        _prepareZoom: function () {
            var a, b = 0,
                d = this.data().zoom,
                e = 1 / this.zoom("value");
            a = d.opts.flipbook;
            var c = a.turn("direction"),
                j = a.data(),
                l = a.offset(),
                i = this.offset(),
                g = {
                    height: a.height()
                }, k = a.turn("view");
            "double" == a.turn("display") && a.data().opts.autoCenter ? k[0] ? k[1] ? (g.width = a.width(), a = h(l.left - i.left, l.top - i.top)) : (g.width = a.width() / 2, b = "ltr" == c ? 0 : g.width, a = h("ltr" == c ? l.left - i.left : l.left - i.left + g.width, l.top - i.top)) : (g.width = a.width() / 2, b = "ltr" == c ? g.width : 0, a = h("ltr" == c ? l.left - i.left + g.width : l.left - i.left, l.top - i.top)) : (g.width = a.width(), a = h(l.left - i.left, l.top - i.top));
            d.zoomer || (d.zoomer = f("<div />", {
                "class": "zoomer",
                css: {
                    overflow: "hidden",
                    position: "absolute",
                    zIndex: "1000000"
                }
            }).mousedown(function () {
                return false
            }).appendTo(this));
            d.zoomer.css({
                top: a.y,
                left: a.x,
                width: g.width,
                height: g.height
            });
            c = k.join(",");
            if (c != d.zoomerView) {
                d.zoomerView = c;
                d.zoomer.find("*").remove();
                for (c = 0; c < k.length; c++) if (k[c]) {
                    var i = j.pageObjs[k[c]].offset(),
                        m = f(j.pageObjs[k[c]]);
                    m.clone().transform("").css({
                        width: m.width() * e,
                        height: m.height() * e,
                        position: "absolute",
                        display: "",
                        top: (i.top - l.top) * e,
                        left: (i.left - l.left - b) * e
                    }).appendTo(d.zoomer)
                }
            }
            return {
                pos: a,
                size: g
            }
        },
        value: function () {
            return this.data().zoom.opts.flipbook.turn("zoom")
        },
        zoomIn: function (a) {
            var b = this,
                d = this.data().zoom,
                e = d.opts.flipbook,
                c = d.opts.max();
            e.offset();
            var r = this.offset();
            if (d.zoomIn) return this;
            e.turn("stop");
            var l = f.Event("zoom.change");
            this.trigger(l, [c]);
            if (l.isDefaultPrevented()) return this;
            var i = j._prepareZoom.call(this),
                g = i.pos,
                k = h(i.size.width / 2, i.size.height / 2),
                l = f.cssPrefix(),
                m = f.cssTransitionEnd(),
                p = e.data().opts.autoCenter;
            d.scale = c;
            e.data().noCenter = !0;
            a = "undefined" != typeof a ? "x" in a && "y" in a ? h(a.x - g.x, a.y - g.y) : f.isTouch ? h(a.originalEvent.touches[0].pageX - g.x - r.left, a.originalEvent.touches[0].pageY - g.y - r.top) : h(a.pageX - g.x - r.left, a.pageY - g.y - r.top) : h(k.x, k.y);
            if (0 > a.x || 0 > a.y || a.x > i.width || a.y > i.height) a.x = k.x, a.y = k.y;
            var n = h((a.x - k.x) * c + k.x, (a.y - k.y) * c + k.y),
                a = h(i.size.width * c > this.width() ? a.x - n.x : 0, i.size.height * c > this.height() ? a.y - n.y : 0),
                n = h(Math.abs(i.size.width * c - this.width()), Math.abs(i.size.height * c - this.height())),
                i = h(Math.min(0, i.size.width * c - this.width()), Math.min(0, i.size.height * c - this.height())),
                o = h(k.x * c - k.x - g.x - a.x, k.y * c - k.y - g.y - a.y);
            o.y > n.y ? a.y = o.y - n.y + a.y : o.y < i.y && (a.y = o.y - i.y + a.y);
            o.x > n.x ? a.x = o.x - n.x + a.x : o.x < i.x && (a.x = o.x - i.x + a.x);
            o = h(k.x * c - k.x - g.x - a.x, k.y * c - k.y - g.y - a.y);
            g = {};
            g[l + "transition"] = l + "transform " + d.opts.easeFunction + " " + d.opts.duration + "ms";
            var q = function () {
                b.trigger("zoom.zoomIn");
                d.zoomIn = true;
                d.flipPosition = h(e.css("left"), e.css("top"));
                e.turn("zoom", c).css({
                    position: "absolute",
                    margin: "",
                    top: 0,
                    left: 0
                });
                var a = e.offset();
                d.axis = h(a.left - r.left, a.top - r.top);
                if (p && e.turn("display") == "double" && (e.turn("direction") == "ltr" && !e.turn("view")[0] || e.turn("direction") == "rtl" && !e.turn("view")[1])) d.axis.x = d.axis.x + e.width() / 2;
                b.zoom("scroll", o);
                b.bind(f.mouseEvents.down, j._eMouseDown);
                b.bind(f.mouseEvents.move, j._eMouseMove);
                f(document).bind(f.mouseEvents.up, d.mouseupEvent);
                b.bind("mousewheel", j._eMouseWheel);
                setTimeout(function () {
                    d.zoomer.hide();
                    d.zoomer.remove();
                    d.zoomer = null;
                    d.zoomerView = null
                },
                50)
            };
            d.zoomer.css(g).show();
            m ? d.zoomer.bind(m, function () {
                f(this).unbind(m);
                q()
            }) : setTimeout(q, d.opts.duration);
            d.zoomer.transform(s(a.x, a.y, !0) + u(c, !0));
            return this
        },
        zoomOut: function (a) {
            var b, d = this,
                e = this.data().zoom,
                c = e.opts.flipbook,
                m = 1 / e.scale,
                l = f.cssPrefix(),
                i = f.cssTransitionEnd();
            b = this.offset();
            a = "undefined" != typeof a ? a : e.opts.duration;
            if (e.zoomIn) {
                var g = f.Event("zoom.change");
                this.trigger(g, [1]);
                if (g.isDefaultPrevented()) return this;
                e.zoomIn = !1;
                e.scale = 1;
                c.data().noCenter = !1;
                d.unbind(f.mouseEvents.down,
                j._eMouseDown);
                d.unbind(f.mouseEvents.move, j._eMouseMove);
                f(document).unbind(f.mouseEvents.up, e.mouseupEvent);
                d.unbind("mousewheel", j._eMouseWheel);
                g = {};
                g[l + "transition"] = l + "transform " + e.opts.easeFunction + " " + a + "ms";
                c.css(g);
                var k = f("<div />", {
                    css: {
                        position: "relative",
                        top: e.flipPosition.y,
                        left: e.flipPosition.x,
                        width: c.width() * m,
                        height: c.height() * m,
                        background: "blue"
                    }
                }).appendTo(c.parent()),
                    g = h(k.offset().left - b.left, k.offset().top - b.top);
                k.remove();
                var p = c.data().opts.autoCenter;
                p && "double" == c.turn("display") && (c.turn("view")[0] ? c.turn("view")[1] || (g.x = "ltr" == c.turn("direction") ? g.x + k.width() / 4 : g.x - k.width() / 4) : g.x = "ltr" == c.turn("direction") ? g.x - k.width() / 4 : g.x + k.width() / 4);
                var q = f.findPos(c[0]);
                b = h(-c.width() / 2 - q.left + k.width() / 2 + g.x + b.left, - c.height() / 2 - q.top + k.height() / 2 + g.y + b.top);
                var n = function () {
                    if (c[0].style.removeProperty) {
                        c[0].style.removeProperty(l + "transition");
                        c.transform(c.turn("options").acceleration ? s(0, 0, true) : "").turn("zoom", 1);
                        c[0].style.removeProperty("margin");
                        c.css({
                            position: "relative",
                            top: e.flipPosition.y,
                            left: e.flipPosition.x
                        })
                    } else c.transform("none").turn("zoom", 1).css({
                        margin: "",
                        top: e.flipPosition.y,
                        left: e.flipPosition.x,
                        position: "relative"
                    });
                    p && c.turn("center");
                    d.trigger("zoom.zoomOut")
                };
                0 === a ? n() : (i ? c.bind(i, function () {
                    f(this).unbind(i);
                    n()
                }) : setTimeout(n, a), c.transform(s(b.x, b.y, !0) + u(m, !0)));
                return this
            }
        },
        flipbookWidth: function () {
            var a = this.data().zoom.opts.flipbook,
                b = a.turn("view");
            return "double" == a.turn("display") && (!b[0] || !b[1]) ? a.width() / 2 : a.width()
        },
        scroll: function (a,
        b, d) {
            var e = this.data().zoom,
                c = e.opts.flipbook,
                j = this.zoom("flipbookWidth"),
                l = f.cssPrefix();
            if (p) {
                var i = {};
                i[l + "transition"] = d ? l + "transform 200ms" : "none";
                c.css(i);
                c.transform(s(-e.axis.x - a.x, - e.axis.y - a.y, !0))
            } else c.css({
                top: -e.axis.y - a.y,
                left: -e.axis.x - a.x
            });
            if (!b) {
                var g, b = h(Math.min(0, (j - this.width()) / 2), Math.min(0, (c.height() - this.height()) / 2)),
                    c = h(j > this.width() ? j - this.width() : (j - this.width()) / 2, c.height() > this.height() ? c.height() - this.height() : (c.height() - this.height()) / 2);
                a.y < b.y ? (a.y = b.y, g = !0) : a.y > c.y && (a.y = c.y, g = !0);
                a.x < b.x ? (a.x = b.x, g = !0) : a.x > c.x && (a.x = c.x, g = !0);
                g && this.zoom("scroll", a, !0, !0)
            }
            e.scrollPos = h(a.x, a.y)
        },
        resize: function () {
            var a = this.data().zoom,
                b = a.opts.flipbook;
            if (1 < this.zoom("value")) {
                var d = b.offset(),
                    e = this.offset();
                a.axis = h(d.left - e.left + (a.axis.x + a.scrollPos.x), d.top - e.top + (a.axis.y + a.scrollPos.y));
                "double" == b.turn("display") && ("ltr" == b.turn("direction") && !b.turn("view")[0]) && (a.axis.x += b.width() / 2);
                this.zoom("scroll", a.scrollPos)
            }
        },
        _eZoom: function () {
            for (var a = this.data().zoom,
            b = a.opts.flipbook, d = b.turn("view"), e = 0; e < d.length; e++) d[e] && this.trigger("zoom.resize", [a.scale, d[e], b.data().pageObjs[d[e]]])
        },
        _eStart: function (a) {
            1 != this.zoom("value") && a.preventDefault()
        },
        _eTurning: function (a, b, d) {
            var e = this,
                a = this.zoom("value"),
                c = this.data().zoom,
                b = c.opts.flipbook;
            c.page = b.turn("page");
            if (1 != a) {
                for (c = 0; c < d.length; c++) d[c] && this.trigger("zoom.resize", [a, d[c], b.data().pageObjs[d[c]]]);
                setTimeout(function () {
                    e.zoom("resize")
                }, 0)
            }
        },
        _eTurned: function (a, b) {
            if (1 != this.zoom("value")) {
                var d = this.data().zoom,
                    e = d.opts.flipbook;
                b > d.page ? this.zoom("scroll", h(0, d.scrollPos.y), !1, !0) : b < d.page && this.zoom("scroll", h(e.width(), d.scrollPos.y), !1, !0)
            }
        },
        _ePressed: function () {
            f(this).data().zoom.draggingCorner = !0
        },
        _eReleased: function () {
            var a = f(this).data().zoom;
            setTimeout(function () {
                a.draggingCorner = !1
            }, 1)
        },
        _eMouseDown: function (a) {
            f(this).data().zoom.draggingCur = f.isTouch ? h(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY) : h(a.pageX, a.pageY);
            return !1
        },
        _eMouseMove: function (a) {
            var b = f(this).data().zoom;
            if (b.draggingCur) {
                b.dragging = !0;
                var a = f.isTouch ? h(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY) : h(a.pageX, a.pageY),
                    d = h(a.x - b.draggingCur.x, a.y - b.draggingCur.y);
                f(this).zoom("scroll", h(b.scrollPos.x - d.x, b.scrollPos.y - d.y), !0);
                b.draggingCur = a;
                return !1
            }
        },
        _eMouseUp: function () {
            var a = f(this).data().zoom;
            a.dragging && f(this).zoom("scroll", a.scrollPos);
            a.draggingCur = null;
            setTimeout(function () {
                a.dragging = !1
            }, 1)
        },
        _eMouseWheel: function (a, b, d, e) {
            a = f(this).data().zoom;
            d = h(a.scrollPos.x + 10 * d, a.scrollPos.y - 10 * e);
            f(this).zoom("scroll", d, !1, !0)
        },
        _eTouchStart: function (a) {
            var b = f(this).data().zoom,
                a = h(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY);
            b.touch = {};
            b.touch.initial = a;
            b.touch.last = a;
            b.touch.timestamp = (new Date).getTime();
            b.touch.speed = h(0, 0)
        },
        _eTouchMove: function (a) {
            var b = f(this).data().zoom,
                d = f(this).zoom("value"),
                e = b.opts.flipbook,
                c = (new Date).getTime(),
                a = h(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY);
            b.touch && (1 == d && !e.data().mouseAction) && (b.touch.motion = h(a.x - b.touch.last.x, a.y - b.touch.last.y), b.touch.speed.x = 0 === b.touch.speed.x ? b.touch.motion.x / (c - b.touch.timestamp) : (b.touch.speed.x + b.touch.motion.x / (c - b.touch.timestamp)) / 2, b.touch.last = a, b.touch.timestamp = c)
        },
        _eTouchEnd: function () {
            var a = f(this).data().zoom;
            if (a.touch && 1 == f(this).zoom("value")) {
                var b = Math.abs(a.touch.initial.y - a.touch.last.y);
                50 > b && (-1 > a.touch.speed.x || -100 > a.touch.last.x - a.touch.initial.x) ? this.trigger("zoom.swipeLeft") : 50 > b && (1 < a.touch.speed.x || 100 < a.touch.last.x - a.touch.initial.x) && this.trigger("zoom.swipeRight")
            }
        },
        _eDestroying: function () {
            var a = this,
                b = this.data().zoom,
                d = b.opts.flipbook;
            this.zoom("zoomOut", 0);
            f.each("tap doubleTap resize zoomIn zoomOut swipeLeft swipeRight".split(" "), function (b, d) {
                a.unbind("zoom." + d)
            });
            for (var e in b.flipbookEvents) Object.prototype.hasOwnProperty.call(b.flipbookEvents, e) && d.unbind(e, b.flipbookEvents[e]);
            d.unbind("touchstart", b.eventTouchStart).unbind("touchmove", b.eventTouchMove).unbind("touchend", b.eventTouchEnd);
            this.unbind("touchstart", j._tap).unbind("click", j._tap);
            b = null;
            this.data().zoom = null
        }
    };
    f.extend(f.fn, {
        zoom: function () {
            var a = arguments;
            if (!a[0] || "object" == typeof a[0]) return j.init.apply(f(this[0]), a);
            if (j[a[0]]) return j[a[0]].apply(f(this[0]), Array.prototype.slice.call(a, 1));
            throw t(a[0] + " is not a method");
        }
    })
})(jQuery);